package NIO;

import java.io.File;
import java.io.FileInputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class NioReadWrite {
    public static void main(String[] args)throws Exception {
        FileChannel channel = new FileInputStream("file1.txt").getChannel();
        ByteBuffer buffer = ByteBuffer.allocate(10);
        while (channel.read(buffer) != -1) {
            buffer.flip();
            while (buffer.hasRemaining()) {
                System.out.print((char) buffer.get());
            }
            buffer.clear();
        }
    }
}
